<?php
namespace app\api\controller\m2979\auto;

use think\Db;
use service\ApiReturn;
use app\api\controller\Base;
use app\member\service\MemberCache;


class Freeform extends Base {
                
/**
 *  查询表单
 *@param  String[字符串]  cheng  昵称
 *@create_time  2024-03-12 15:43:19
 */ 
public function get_form($data = [], $user = [])
{
    $headLang  = request()->header('lang');
    $where = [];
  
    $order = 'freeform.aid desc';
	if (!empty($data['sort_field'])) {
		$order = 'freeform.'.$data['sort_field'].' '.$data['sort_type'];
	}

    $where[] = ['freeform.is_del', '=', 0]; 
 	if (!empty($data['cheng'])) {
		$where[] = ['freeform.cheng', '=', $data['cheng']]; 
 	}

    $select_info = array (
  'gedan' => 
  array (
    1 => '晴天',
    2 => '花海',
    3 => '七里香',
  ),
'member_user' => MemberCache::getUserListToMemberID(MemberID), 
'shifoupaidan' => MemberCache::getPropertyListToID(MemberID, 16895), 
); 
p($select_info);
	$dataList = Db::table('lb_free_form_')
		->alias('freeform')
		->field("freeform.cheng,freeform.shifoupaidan,freeform.geshou,freeform.gedan,freeform.xitongyuangong,freeform.create_time")
		->where($where)
		->order($order)
		->find();
	if ($dataList){
		$infodataList = $dataList;
			$infodataList['shifoupaidan_name'] = $select_info['shifoupaidan']["{$infodataList['shifoupaidan']}"] ?? '';
			$infodataList['gedan_name'] = $select_info['gedan']["{$infodataList['gedan']}"] ?? '';
			$infodataList['xitongyuangong_name'] = $select_info['member_user']["{$infodataList['xitongyuangong']}"] ?? '';
			$infodataList['create_time'] = $infodataList['create_time'];
		$dataList = $infodataList;
	}

    if($dataList){
        return ApiReturn::r(1, $dataList, '请求成功');
    }else{
        return ApiReturn::r(1, [], '暂无数据');
    }
}

}